package com.mayikt;

import java.util.concurrent.locks.LockSupport;

/**
 * @ClassName Test015
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test015 {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            //当前释放cpu执行权，变为阻塞状态  // 让当前线程变为阻塞状态
            System.out.println("1");
            LockSupport.park();
            System.out.println("2" + Thread.currentThread().isInterrupted());
        });
        thread.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        // 中断：阻塞 继续将后面代码执行完毕。
        thread.interrupt();
        ;
//        //唤醒刚才阻塞的线程
//        System.out.println("唤醒阻塞的线程");
//        LockSupport.unpark(thread);
    }
}
